<template>
    <div class="tech-box"> 
      <div class="tech-box-border">
        <div class="border-beam-top"></div>
        <div class="border-beam-bottom"></div>
        <div class="data-flow"></div>
        <div v-if="title" class="tech-box-title">
          <span>{{ title }}</span>
        </div>
        <div class="tech-box-content">
          <slot></slot>
        </div>
      </div>
    </div>
  </template>
   
  <script lang="ts">
  import { defineComponent } from 'vue'
  export default defineComponent({
    name: 'TechBox',
  })
  </script>
  <script setup lang="ts">
  defineProps({
    title: {
      type: String,
      default: ''
    }
  })
  </script>
  <style lang="scss" scoped>
  .tech-box {
    display: inline-block;
    position: relative;
    width: 100%;
    &-border {
      position: relative;
      background: rgba(6, 23, 37, 0.8);
      border-radius: 4px;
      box-shadow: 0 0 15px rgba(0, 149, 255, 0.15);
      overflow: hidden;   
      &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(0, 219, 255, 0.05), rgba(6, 23, 37, 0.6));
        pointer-events: none;
      }
      &::after {
        content: '';
        position: absolute;
        inset: 0;
        border: 1px solid transparent;
        border-image: linear-gradient(
          to right,
          rgba(0, 180, 255, 0) 0%,
          rgba(0, 180, 255, 0.5) 25%,
          rgba(0, 180, 255, 0.8) 50%,
          rgba(0, 180, 255, 0.5) 75%,
          rgba(0, 180, 255, 0) 100%
        ) 1;
        pointer-events: none;
        z-index: 5;
      }
    }
    .border-beam-top {
      position: absolute;
      top: 0;
      left: 0;
      width: 60px;
      height: 1px;
      background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 180, 255, 0.8),
        transparent
      );
      filter: blur(1px);
      z-index: 10;
      box-shadow: 0 0 10px rgba(0, 180, 255, 0.6);
      animation: beam-top 5s linear infinite;
      opacity: 0.8;
    }
    .border-beam-bottom {
      position: absolute;
      bottom: 0;
      right: 0;
      width: 60px;
      height: 1px;
      background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 180, 255, 0.8),
        transparent
      );
      filter: blur(1px);
      z-index: 10;
      box-shadow: 0 0 10px rgba(0, 180, 255, 0.6);
      animation: beam-bottom 5s linear infinite;
      animation-delay: 2.5s;
      opacity: 0.8;
    }
    
    .data-flow {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      overflow: hidden;
      z-index: 2;
      pointer-events: none;
      opacity: 0.1;
      
      &::before {
        content: '';
        position: absolute;
        width: 200%;
        height: 200%;
        top: -50%;
        left: -50%;
        background-image: 
          radial-gradient(rgba(0, 180, 255, 0.2) 1px, transparent 1px);
        background-size: 30px 30px;
        animation: data-flow 30s linear infinite;
        will-change: transform;
      }
    }
    
    &-title {
      position: relative;
      margin-top: 10px;
      padding: 5px 15px;
      text-align: center;
      
      span {
        color: #ffffff;
        font-size: 16px;
        font-weight: 500;
        text-shadow: 0 0 4px rgba(0, 209, 255, 0.8);
        position: relative;
        z-index: 2;
        letter-spacing: 1px;
        
        &::after {
          content: '';
          position: absolute;
          bottom: -5px;
          left: 0;
          width: 100%;
          height: 1px;
          background: linear-gradient(
            90deg,
            transparent,
            rgba(0, 180, 255, 0.5),
            transparent
          );
          transform: scaleX(0.7);
          transform-origin: center;
          opacity: 0.7;
        }
      }
    }
    
    &-content {
      position: relative;
      z-index: 2;
    }
    
    &:hover {
      .border-beam-top,
      .border-beam-bottom {
        opacity: 1;
        box-shadow: 0 0 15px rgba(0, 180, 255, 0.8);
      }
      
      .tech-box-border {
        box-shadow: 0 0 20px rgba(0, 149, 255, 0.25);
      }
    }
  }
  
  @keyframes beam-top {
    0% {
      left: -60px;
      opacity: 0;
    }
    10% {
      opacity: 0.8;
    }
    90% {
      opacity: 0.8;
    }
    100% {
      left: calc(100% + 60px);
      opacity: 0;
    }
  }
  
  @keyframes beam-bottom {
    0% {
      right: -60px;
      opacity: 0;
    }
    10% {
      opacity: 0.8;
    }
    90% {
      opacity: 0.8;
    }
    100% {
      right: calc(100% + 60px);
      opacity: 0;
    }
  }
  
  @keyframes data-flow {
    0% {
      transform: translateY(0) rotate(0deg);
    }
    100% {
      transform: translateY(-20%) rotate(10deg);
    }
  }
  </style>